package com.lvmama.task.common.vo;


import com.lvmama.comm.pet.po.pub.TaskResult;
import com.lvmama.task.common.utils.TaskUtil;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.<p/>
 * User: troy-kou<p/>
 * Date: 14-1-7<p/>
 * Time: 下午4:26<p/>
 * Email:kouhongyu@163.com<p/>
 */
public class TaskJobLog implements Serializable {

    private static final long serialVersionUID = 5762807216778304398L;

    /**
     * 日志ID
     */
    private Long logId;
    /**
     * mongodb Id
     */
    private String taskJobLogId;
    /**
     * 任务ID
     */
    private Long taskId;
    /**
     * 任务名称
     */
    private String taskName;
    /**
     * 远程任务返回状态(新)
     */
    private TaskResult.RUN_STATUS resultRunStatus;
    /**
     * 远程任务返回结果
     */
    private String resultInfo;
    /**
     * 异常信息
     */
    private String exceptionInfo;
    /**
     * 任务开始时间
     */
    private Date startTime;
    /**
     * 任务结束时间
     */
    private Date endTime;
    /**
     * 任务耗时的毫秒数
     */
    private Long timeConsuming;

    public TaskJobLog() {
        logId = System.currentTimeMillis();
    }

    public Long getLogId() {
        return logId;
    }

    public void setLogId(Long logId) {
        this.logId = logId;
    }

    public Long getTaskId() {
        return taskId;
    }

    public void setTaskId(Long taskId) {
        this.taskId = taskId;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getResultInfo() {
        return resultInfo;
    }

    public void setResultInfo(String resultInfo) {
        this.resultInfo = resultInfo;
    }

    public String getExceptionInfo() {
        return exceptionInfo;
    }

    public void setExceptionInfo(String exceptionInfo) {
        this.exceptionInfo = exceptionInfo;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public TaskResult.RUN_STATUS getResultRunStatus() {
        return resultRunStatus;
    }

    public void setResultRunStatus(TaskResult.RUN_STATUS resultRunStatus) {
        this.resultRunStatus = resultRunStatus;
    }

    public String getTaskJobLogId() {
        return taskJobLogId;
    }

    public void setTaskJobLogId(String taskJobLogId) {
        this.taskJobLogId = taskJobLogId;
    }

    public Long getTimeConsuming() {
        return timeConsuming;
    }

    public void setTimeConsuming(Long timeConsuming) {
        this.timeConsuming = timeConsuming;
    }

    /**
     * 任务耗时格式化
     *
     * @return
     */
    public String getTimeConsumingFormat() {
        return TaskUtil.calculateTimeConsumingFormat(timeConsuming);
    }

    public String toString() {
        return "TaskJobLog{" +
                "logId=" + logId +
                ", taskId=" + taskId +
                ", taskName='" + taskName + '\'' +
                ", resultRunStatus=" + resultRunStatus +
                ", resultInfo='" + resultInfo + '\'' +
                ", exceptionInfo='" + exceptionInfo + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                '}';
    }
}
